<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %><%--
  Created by IntelliJ IDEA.
  User: 27933
  Date: 2021/10/7
  Time: 14:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    Class.forName("com.mysql.cj.jdbc.Driver");
    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/huohua?serverTimezone=UTC", "root", "123456");
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select * from customer");
%>
<c:if test="${empty sessionScope.name}">
    <a href="login.jsp">登录后查看</a>
    <a href="register.jsp">没有账号请注册</a>
</c:if>
<c:if test="${not empty sessionScope.name}">
    欢迎你,${sessionScope.name}
    <a href="logoutServlet">注销登录</a>
</c:if>
<div class="container">
    <table border="1">
        <caption>员工信息表</caption>
        <thead>
        <tr>
            <td>序号</td>
            <td>ID</td>
            <td>姓名</td>
            <td>性别</td>
            <td>年龄</td>
            <td>电话</td>
            <td>邮箱</td>
        </tr>
        </thead>
            <%
                int index = 1;
                while (rs.next()) {
            %>
            <tr>
                <td><%=index++%>
                </td>
                <td><%=rs.getInt("id")%>
                </td>
                <td><%=rs.getString("name")%>
                </td>
                <td><%=rs.getString("gender")%>
                </td>
                <td><%=rs.getInt("age")%>
                </td>
                <td><%=rs.getString("phone")%>
                </td>
                <td><%=rs.getString("email")%>
                </td>
                <td><a href="index.jsp?id=<%=rs.getInt("id")%> &title = 修改员工信息">修改</a></td>
            </tr>
            <%}%>
    </table>


</div>

</body>
</html>
